#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define LL long long
using namespace std;

int main() {
  freopen("dress.in", "r", stdin);
  freopen("dress.out", "w", stdout);
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m, k, p, p_of_PS = 0;
  LL ans = 0;

  cin >> n >> m >> k >> p;
  vector<vector<int>> g(n + 1, vector<int>());
  vector<int> sum(m + 1, 0);
  for (int i = 0; i < p; i++) {
    string type;
    int u, v;

    cin >> type >> u >> v;
    if (type == "CP") {
      g[u].push_back(v);
    } else {
      sum[u]++;
      p_of_PS++;
    }
  }
  for (int i = 1; i <= n; i++) {
    int tot = p_of_PS;
    for (int j : g[i]) {
      tot -= sum[j];
    }
    ans += (LL)(m - g[i].size()) * k - tot;
  }
  cout << ans << "\n";
  return 0;
}